package com.necsv;

import java.io.IOException;

import com.necsv.Mylog.Mylog;

import android.app.Activity;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class WallPaperActivity extends Activity implements View.OnClickListener
{
	private ImageView display;
	private ImageView image1;
	private ImageView image2;
	private ImageView image3;
	private int toPhone;
	private Button btnWall;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.wallpaper);
		display = (ImageView)findViewById(R.id.img_wallpaperMain);
		image1 = (ImageView)findViewById(R.id.img_wall1);
		image2 = (ImageView)findViewById(R.id.img_wall2);
		image3 = (ImageView)findViewById(R.id.img_wall3);
		
		btnWall = (Button)findViewById(R.id.btn_wallpaper);
		toPhone = R.drawable.i;
		image1.setOnClickListener(this);
		image2.setOnClickListener(this);
		image3.setOnClickListener(this);
		btnWall.setOnClickListener(this);
		
		
	}

	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.img_wall1:
			display.setImageResource(R.drawable.i);
			toPhone = R.drawable.i;
			break;
		case R.id.img_wall2:
			display.setImageResource(R.drawable.i141);
			toPhone = R.drawable.i141;
			break;
		case R.id.img_wall3:
			display.setImageResource(R.drawable.i142);
			toPhone = R.drawable.i142;
			break;
		case R.id.btn_wallpaper:
			Mylog.Toat(this, "Set Wallpaper");
			Bitmap whatever = BitmapFactory.decodeStream(getResources().openRawResource(toPhone));
			try {
				getApplicationContext().setWallpaper(whatever);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		default:
			break;
		}
		
	}
	
	
}
